const Joi = require("joi");
module.exports = class PayProductController extends colpu.Controller {
  /**
   * @api {get} /pay/list 产品列表
   * @apiDescription 产品列表
   * @apiGroup  产品接口
   * @apiVersion 1.0.0
   *
   * @apiSuccess {Number} status 状态码
   * @apiSuccess {String} message 消息
   * @apiSuccess {Object} data 返回结果
   * @apiSuccess {Boolen} isDecrypt 是否需要解密
   * @apiSuccessExample {json} Success-Response:
   * HTTP/1.1 200 OK
      {
        "data": {
          ...
        },
        "status": 0,
        "message": "ok"
      }
  */
  async payProductlist(ctx) {
    await ctx.validateAsync({
      query: {
        isios: Joi.number().integer(),
      },
      status: 10001,
    });
    const { isios = 0 } = ctx.query;
    const products = await this.service.pay.payProductList();
    const payTypes = await this.service.pay.payType(isios);
    ctx.respond({ products, payTypes });
  }
};
